<template>
  <el-container>
    <el-header style="transform: scale(0)"> </el-header>
    <el-main style="margin-top: -72px">
      <AdminMain>111</AdminMain>
    </el-main>
  </el-container>
</template>

<script setup>
import AdminHeader from "@/components/homeHeader.vue";
import AdiminMain from "@/components/AdminMain.vue";
import { ref, onMounted } from 'vue';
import axios from 'axios';

const checkAdmin = async () => {
  try {
    const response = await axios.get('http://localhost:8000/usertype/checkAdmin', { withCredentials: true });
    if (response.data.status === 'error' || !response.data.isAdmin) {
      window.location.href = 'http://localhost:5173/#/403';
    }
  } catch (error) {
    console.error('Error checking admin status:', error);
    window.location.href = 'http://localhost:5173/#/403';
  }
};

onMounted(() => {
  checkAdmin().then(() => {
    fetchUsers();
  });
});
</script>

<style></style>
